﻿using UnityEditor;
using UnityEngine;

namespace HKTools
{
    /// <summary>
    /// HK_FollowTarget 的 Inspector 编辑器拓展
    /// </summary>
    [CanEditMultipleObjects]
    [CustomEditor(typeof(HK_FollowTarget))]
    public class HK_FollowTargetEditor : Editor
    {
        public override void OnInspectorGUI()
        {
            GUILayout.Space(5);

            if (GUILayout.Button("根据物体名称，添加 Target 类型"))
            {
                HK_AddTargetEnumValue.AddTargetType((HK_BaseTarget)target);
            }

            GUILayout.Space(10);

            // 更新序列化对象  
            serializedObject.Update();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("targetType"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("FOV"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("distance"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("minDis"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("maxDis"));

            // 应用修改  
            serializedObject.ApplyModifiedProperties();
        }
    }
}